package com.haixee.parkdemo.log.controller;

import com.haixee.parkdemo.common.context.WebContextHolder;
import com.haixee.parkdemo.common.response.ResResult;
import com.haixee.parkdemo.common.response.ResUtil;
import com.haixee.parkdemo.log.model.Log;
import com.haixee.parkdemo.log.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/")
public class LogController {

    @Autowired
    private LogService logService;

    @PostMapping("/add")
    public ResResult add(@RequestBody Log log) {
        logService.writeLog(WebContextHolder.getUid(), log.getContent());
        return ResUtil.success();
    }

    @GetMapping
    public ResResult list() {
        return ResUtil.success(logService.getList(WebContextHolder.getUid()));
    }
}
